styleproperties: Speed up style_property_lookup()
authorBenjamin Otte <otte@redhat.com>
Mon, 16 May 2011 20:35:21 +0000 (22:35 +0200)
committerBenjamin Otte <otte@redhat.com>
Wed, 18 May 2011 20:17:57 +0000 (22:17 +0200)
Use the already existing bsearch version instead of iterating the array
manually.

gtk/gtkstyleproperties.c

index 2bb8f5a6d57dbf85ae8bdd1156fa3baec63e7536..b1adea1874fa41e2f0d78b71b794d2a4644230c4 100644 (file)
@@ -490,7 +490,6 @@ gtk_style_properties_lookup_property (const gchar             *property_name,
   GtkStylePropertiesClass *klass;
   gboolean found = FALSE;
   GQuark quark;
-  gint i;
 
   g_return_val_if_fail (property_name != NULL, FALSE);
 
@@ -503,23 +502,17 @@ gtk_style_properties_lookup_property (const gchar             *property_name,
       return FALSE;
     }
 
-  for (i = 0; i < properties->len; i++)
-    {
-      node = &g_array_index (properties, PropertyNode, i);
+  node = property_node_lookup (quark);
 
-      if (node->property_quark == quark)
-        {
-          if (pspec)
-            *pspec = node->pspec;
+  if (node)
+    {
+      if (pspec)
+        *pspec = node->pspec;
 
-          if (parse_func)
-            *parse_func = node->parse_func;
+      if (parse_func)
+        *parse_func = node->parse_func;
 
-          found = TRUE;
-          break;
-        }
-      else if (node->property_quark > quark)
-        break;
+      found = TRUE;
     }
 
   g_type_class_unref (klass);